#!/bin/bash
#
# Volodymyr P Sergiievskyi, voov.rat@gmail.com
#
#  splitParagraphs <file> <output_folder>
#
# Split the txt file to paragraphs
#
# Paragraphs are delimited by the empty line
#
#  in the output_folder the separate files for each paragraph are created
#
N=0
IFS=$'\n'
for par in $(cat $1 | tr $'\n' '@' | sed 's:@@:\&:g' | tr '&' $'\n')
do
	N=$((N+1))

	echo $par | tr '@' $'\n' > $2/par$N.txt
			
done
